import axios from './interceptor'

// 发送验证码注册
const sendEmailCode = (email: string) => {
  return axios.post('/emailer/sendemail', { email })
}

// 注册用户
const register = (
  email: string,
  code: string,
  username: string,
  password: string
) => {
  return axios.post('emailer/register', { email, code, username, password })
}

// 登录用户
const loginUser = (email: string, password: string, code: string) => {
  return axios.post('emailer/login', { email, password, code })
}


// 更新用户
const  updateUser =  (where:FormData)=> {
  return axios.put('emailer/user', where, {
    headers: {
      "Content-Type": "multipart/form-data",
    },
  })
}

// 修改密码
const  changePassword =(email:string, password:string) =>{
  return axios.post('emailer/changePassword', { email, password })
}

export { sendEmailCode, register, loginUser,updateUser,changePassword }
